{ Google Code Jam 2011. Round 1C.
  Problemset: http://code.google.com/codejam/contest/dashboard?c=1128486
  Problem A.
  Verdict: Correct/Correct
}
uses
  SysUtils, Math;

var
  t,tt,n,m,bl,i,j:longint;
  a:array[0..60,0..60] of byte;
  ch:char;
  f:boolean;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(t);
for tt:=1 to t do begin
  fillchar(a,sizeof(a),0);
  writeln('Case #',tt,': ');
  readln(n,m);
  bl:=0;
  f:=true;
  for i:=1 to n do begin
    for j:=1 to m do begin
      read(ch);
      if ch='#' then begin
        a[i][j]:=1;
        inc(bl);
      end;
    end;
    readln;
  end;
  if bl mod 4=0 then begin
    for i:=1 to n-1 do begin
      for j:=1 to m-1 do begin
        if (a[i][j]=1) then begin
          if (a[i+1][j]=1) and (a[i][j+1]=1) and (a[i+1][j+1]=1) then begin
            a[i][j]:=2;
            a[i+1][j]:=2;
            a[i][j+1]:=2;
            a[i+1][j+1]:=2;
          end else begin
            f:=false;
            break;
          end;
        end;
      end;
      if not f then break;
    end;
  end else f:=false;
  for i:=1 to n do begin
    for j:=1 to m do begin
      if a[i][j]=1 then f:=false;
      if not f then break;
    end;
    if not f then break;
  end;
  if not f then writeln('Impossible') else begin
    for i:=1 to n do begin
      for j:=1 to m do begin
        if a[i][j]=0 then write('.') else
        if a[i][j]=2 then begin
          if a[i-1][j]=3 then begin
            write('\/');
            a[i][j]:=4;
            a[i][j+1]:=4;
          end else begin
            write('/\');
            a[i][j]:=3;
            a[i][j+1]:=3;
          end;
        end;
      end;
      writeln;
    end;
  end;
end;
end.
